<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('已安装应用名称列表')" />
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden"  th:value="${productId}" name="productId"/>
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>应用：</label>
                                <select name="productId" id="productId">
                                    <option value="">请选择应用</option>
                                    <option th:each="product:${productList}" th:text="${product.name}" th:value="${product.id}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;查询</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="product:product:version:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="product:version:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="product:product:version:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />

    <script th:inline="javascript">
        var yes_no = [[${@dict.getType('sys_business_yes_no')}]];
        var prefix = ctx + "product/product";
        $(function() {
            var productId= [[${productId}]];
            var options = {
                createUrl: prefix + "/version/form",
                updateUrl: prefix + "/version/form/{id}",
                removeUrl: prefix + "/version/remove",
                url: prefix + "/getVersionList",
                modalName: "版本",
                columns: [{
                    checkbox: true
                    },
                    {
                        field: 'id',
                        title: '${comment}',
                        visible: false
                    },
                    {
                        field: 'name',
                        title: '应用名称'
                    },
                    {
                        field: 'versionName',
                        title: '版本名称'
                    },
                    {
                        field: 'version',
                        title: '版本号'
                    },
                    {
                        field: 'upgradeContent',
                        title: '更新内容'
                    },
                    {
                        field: 'isOnline',
                        title: '是否上线',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(yes_no, value);
                        }
                    },
                    {
                        field: 'isForce',
                        title: '强制更新',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(yes_no, value);
                        }
                    },
                    {
                        field: 'publishTime',
                        title: '发布时间'
                    }]
            };
            $.table.init(options);
        });

        function submitHandler() {
            $.modal.closeAll();
        }
    </script>
</body>
</html>